package com.huterox.todoscheduler.core;


import com.huterox.todoscheduler.common.TaskManager;
import com.huterox.todoscheduler.config.ConfigEngine;
import com.huterox.todoscheduler.core.execute.ExecuteCore;
import com.huterox.todoscheduler.core.execute.impl.DefaultExecuteCore;
import com.huterox.todoscheduler.core.global.TodoListTemplateMap;
import com.huterox.todoscheduler.core.wapper.TaskWrapper;

import java.io.Serializable;

/**
 * 对外提供的任务清单执行器,给用户happy的
 * */
public class ExecuteManager implements Serializable {


    public static void execute(String ListName){

        if(TodoListTemplateMap.getInstance().getSize()!=0){
            ExecuteCore defaultExecuteCore = new DefaultExecuteCore();
            defaultExecuteCore.execute(ListName);
            TaskWrapper taskWrapper = new TaskWrapper();
            //通过这个把执行清单进行提交
            taskWrapper.setExecuteCore(defaultExecuteCore);

            TaskManager o = (TaskManager) ConfigEngine.corePart.get(TaskManager.class);
            o.submitTask(taskWrapper,defaultExecuteCore.getClsId());
        }


    }

    public static void shutdown(){
        TaskManager o = (TaskManager) ConfigEngine.corePart.get(TaskManager.class);
        o.shutdown();
    }

}
